<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<%
  @body_classes ||= []
  css_bundle :login
  js_bundle :change_password
  @headers = false
  @body_classes << "modal" 
%>

<% content_for :page_title do %><%= t :page_title, "Change Password" %><% end %>

<div id='modal-box'>
  <div style="margin: 80px 10px 0">
    <h2><%= t 'titles.change_password', "Change login password for %{user}", :user => @pseudonym.user.name %></h2>
    <%= form_for @pseudonym, :url => change_password_url(@pseudonym.id, @cc.confirmation_code), :html => {:method => :post, :id => "change_password_form"} do |form| %>
    <table class="formtable">
      <% if @password_pseudonyms.length > 1 %>
        <tr>
          <td><label for="pseudonym_id_select"><%= before_label :which_login_to_change, "Which login to change" %></label></td>
          <td>
            <select id="pseudonym_id_select" name="pseudonym[id]">
              <% @password_pseudonyms.each do |p| %>
                <option value="<%= p.id %>" <%= 'selected' if p == @pseudonym %> ><%= p.unique_id %> &nbsp;&nbsp;-&nbsp;&nbsp; <%= p.account.display_name %></option>
              <% end %>
            </select>
          </td>
        </tr>
      <% else %>
        <tr>
          <td colspan="2">
            <div style="padding: 5px 0; font-weight: bold; font-size: 1.1em;"><%= @cc.path %></div>
          </td>
        </tr>
      <% end %>
      <tr>
        <td style="vertical-align: middle;"><%= form.blabel :password, form.object.new_record? ? t('labels.password', "Password") : t('labels.new_password', "New Password") %></td>
        <td>
          <%= form.password_field :password, :class => "text" %>
        </td>
      </tr><tr>
        <td style="vertical-align: middle;" class="nobr"><%= form.blabel :password_confirmation, :en => "Confirm New Password" %></td>
        <td><%= form.password_field :password_confirmation, :class => "text" %>
        </td>
      </tr><tr>
        <td colspan="2" style="text-align: right;"><button type="submit" class="btn"><%= t 'buttons.update_password', "Update Password" %></button></td>
      </tr>
    </table>
    <% end %>
  </div>
</div>
